package com.uplooking.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.uplooking.service.CheckService;

@Controller
public class CheckController {

	@Autowired
	private CheckService checkService;

	@RequestMapping(value = "/check/index", method = RequestMethod.GET)
	public String methodCheck1() {
		return "service/check";
	}

	@ResponseBody
	@RequiresPermissions("check!list")
	@RequestMapping(value = "/check/list", method = RequestMethod.GET, produces = { "application/json;charset=utf-8" })
	public String methodCheck2(String ckctid, int index, int size, int step) throws Exception {
		return JSONObject.toJSONString(checkService.getCheckList(ckctid, index, size, step));
	}

	@ResponseBody
	@RequiresPermissions("check!add")
	@RequestMapping(value = "/check/add", method = RequestMethod.POST, produces = { "application/json;charset=utf-8" })
	public String methodCheck3(String rnrtid, String[] ckproblem, String ckdesc) throws Exception {
		return JSONObject.toJSONString(checkService.addCheck(rnrtid, ckproblem, ckdesc));
	}

	@ResponseBody
	@RequiresPermissions("check!do")
	@RequestMapping(value = "/check/do", method = RequestMethod.GET, produces = { "application/json;charset=utf-8" })
	public String methodCheck4(int ckid, String ckctid) throws Exception {
		return JSONObject.toJSONString(checkService.checkOk(ckid, ckctid));
	}
}
